#docker rmi -f bitnami/postgresql-repmgr:11
docker pull bitnami/postgresql-repmgr:11
rm -rf /cardone/docker/images/bitnami/postgresql-repmgr_11.tar
mkdir -p /cardone/docker/images/bitnami
docker save bitnami/postgresql-repmgr:11 > /cardone/docker/images/bitnami/postgresql-repmgr_11.tar
#docker load < /cardone/docker/images/bitnami/postgresql-repmgr_11.tar



#docker rmi -f bitnami/pgpool:4
docker pull bitnami/pgpool:4
rm -rf /cardone/docker/images/bitnami/pgpool_4.tar
mkdir -p /cardone/docker/images/bitnami
docker save bitnami/pgpool:4 > /cardone/docker/images/bitnami/pgpool_4.tar
#docker load < /cardone/docker/images/bitnami/pgpool_4.tar



# docker node update --label-rm cardone-postgresql_pgpool cardone-01-01
# docker node update --label-rm cardone-postgresql_postgresql-1 cardone-01-01
# docker node update --label-rm cardone-postgresql_postgresql-2 cardone-01-01

docker node update --label-add cardone-postgresql_pgpool=true cardone-01-02
docker node update --label-add cardone-postgresql_postgresql-1=true cardone-01-03
docker node update --label-add cardone-postgresql_postgresql-2=true cardone-01-04
docker node update --label-add cardone-postgresql_postgresql-3=true cardone-01-05

docker stack rm cardone-postgresql

docker stack deploy -c /cardone/middlewares/postgresql/prod.yml cardone-postgresql

for i in {1..10}
do  
sleep $i

docker stack ps cardone-postgresql

docker service ls
done

docker service logs cardone-postgresql_pgpool -f --tail 300

docker service logs cardone-postgresql_postgresql-1 -f --tail 300

docker service logs cardone-postgresql_postgresql-2 -f --tail 300



